<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="com.lmpop.trade.ts_category.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.lmpop.trade.tb_commpara.Tb_commparaInfo" %>
<%@ page import="com.lmpop.frame.util.PageTools" %>
<%
	request.setCharacterEncoding("UTF-8");
	Map ts_category = new Hashtable();
	Ts_categoryInfo ts_categoryInfo = new Ts_categoryInfo();
	String s_title = "";
	if(request.getParameter("s_title")!=null){
		  s_title = request.getParameter("s_title");
		  ts_category.put("cat_name",s_title);
	}
 
 
	
	String class_type = "2";
 
	if(request.getParameter("class_type")!=null){
		 class_type = request.getParameter("class_type");
 
	}
	ts_category.put("class_type",class_type);

	String up_classId="",break_cat_id="";
	if (request.getParameter("up_classId") != null && !request.getParameter("up_classId").equals("")) {
		up_classId = request.getParameter("up_classId");
		if(!up_classId.equals("000000000000000")){
			break_cat_id=ts_categoryInfo.getUp_cat_id(up_classId);
		}
	}else{
	    up_classId="000000000000000";
	}
			
	ts_category.put("up_cat_id",up_classId);
	
	
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
 

	List list = ts_categoryInfo.getListByPage(ts_category,Integer.parseInt(iStart),limit);
	int counter = ts_categoryInfo.getCountByObj(ts_category);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?s_title="+s_title+"&class_type="+class_type+"&up_classId="+up_classId+"&iStart=",Integer.parseInt(iStart),limit);

	
	String para ="s_title="+s_title+"&class_type="+class_type+"&up_classId="+up_classId+"&iStart="+Integer.parseInt(iStart); 
	
	Tb_commparaInfo tb_commparaInfo = new Tb_commparaInfo(); 
	String state = tb_commparaInfo.getSelectItem("40",class_type);  
	String obj_name = tb_commparaInfo.getOneComparaPcode1("40",class_type);
%>
<html>
  <head>
	<title><%=obj_name%>分类管理</title>
 
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<script language="javascript" type="text/javascript" src="/program/admin/category/js_category.js"></script>
  </head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1><%=obj_name%>分类管理</h1>
			</td>
			<td>
				<a href="/program/admin/category/addInfo.jsp?class_type=<%=class_type%>">
				<img src="/program/admin/index/images/post.gif" /></a>
			</td>
		</tr>
	</table>
	
	<form action="/program/admin/category/index.jsp" name="indexForm" method="post">
	
	<table width="100%" cellpadding="0" cellspacing="0"  class="dl_su">
		<tr>
			<td align="left">
				分类名称:<input name="s_title" id="s_title" type="text" onBlur="this.value=ignoreSpaces(this.value);" />&nbsp;&nbsp;
				
				<font color="red">分类类型:</font><select name="class_type">
							<%=state%>
						 </select>&nbsp;&nbsp;
				
				<input name="searchInfo" type="button" value="查询" onclick="document.indexForm.submit();"/>	
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td align="center"><%=pageString %></td></tr>
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delNewsInfo()" value="删除" class="buttab"/>
 
				<input type="button" name="sortN" onclick="sortNews(this)" value="排序" class="buttab"/>
        <%
        if(!up_classId.equals("000000000000000")){        
        %>
		   
         <input type="button" name="ret" onclick="window.location.href='/program/admin/category/index.jsp?class_type=<%=class_type%>&up_classId=<%=break_cat_id%>'" value="返回" class="buttab"/>
		   
		   <%}%>
			</td>
			<td>
				总计:<%=counter %>
条
			</td>
		</tr>
	</table>
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center"><input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
			
		  	<th>分类名称</th>
		  	
		  	<th>分类标识</th>
		  	
		  	<th>显示顺序</th>
		  	
		  	<th>是否显示</th>
		  	
		  	<th>新增子分类</th>
		  
	  		<th width="10%">修改</th>
 
	  		
	  		<th width="10%">删除</th>

		</tr>
		
		
		<% 
		  		for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
		  			String cat_id="",cat_name="",up_cat_id="",cat_level="",g_class_type="",is_dis="",sort_no="",rsrv_str1="",rsrv_str2="",rsrv_str3="",remark="";
		  			  	if(map.get("cat_id")!=null) cat_id = map.get("cat_id").toString();
						  	if(map.get("cat_name")!=null) cat_name = map.get("cat_name").toString();
						  	if(map.get("up_cat_id")!=null) up_cat_id = map.get("up_cat_id").toString();
						  	if(map.get("cat_level")!=null) cat_level = map.get("cat_level").toString();
						  	if(map.get("class_type")!=null) g_class_type = map.get("class_type").toString();
						  	if(map.get("is_dis")!=null) is_dis = map.get("is_dis").toString();
						  	if(map.get("sort_no")!=null) sort_no = map.get("sort_no").toString();
						  	String	distring="";
						  	if(is_dis.equals("0"))
						  	{
 
						  	  distring  ="显示";
						    }
						    else if(is_dis.equals("1"))
						    {
						  
    distring  ="不显示";
						    }	
						  Boolean hasDown =  ts_categoryInfo.checkSonById(cat_id);				 

		  %>
		
		<tr>
			<td width="5%" align="center"><input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=cat_id %>" /></td>
			
		  	<td>
		  		<%
		  		
		  		 if(hasDown){
		  		
		  		%>
 
		  		
		  		<input type="hidden" name="hasdown<%=i%>" value="1" id="hasdown<%=i%>" />
		  		
		  		<a href="/program/admin/category/index.jsp?up_classId=<%=cat_id%>&class_type=<%=class_type%>" title="查看该分类下级"><img src="/program/admin/images/1.gif" border="0" style="cursor:pointer;"/>
		  			<%=cat_name%>
		  		</a>
		  		
		  		<%}else{%>
		  		
		  		<%=cat_name%>
				
		  		<%}%>
		  		
		  		</td>
		  	
		  	<td><%=cat_id%></td>
		  	
		  	<td><input type="text" id="<%=cat_id%>" name="<%=cat_id%>" value="<%=sort_no%>" size="4" maxlength="4" onKeyUp="if(!/^[0-9][0-9]*$/.test(this.value))this.value=''"></td>
		  	
		  	<td><%=distring%></td>
		  	
		  	<td>&nbsp;<a href="/program/admin/category/addInfo.jsp?up_cat_id=<%=cat_id%>&class_type=<%=class_type%>&class_level=<%=cat_level%>" title="新增子分类"><img src="/program/admin/images/add.gif" border="0" style="cursor:pointer;" /></a></td>
		  	
			<td width="10%"><a href="/program/admin/category/updateInfo.jsp?cat_id=<%=cat_id %>&class_type=<%=class_type%>&<%=para%>"><img src="/program/admin/images/edit.gif" title="修改" border="0"/></a></td>
	  		<td width="10%"><a href="javascript:delOneNews('<%=i%>','<%=cat_id%>');"><img src="/program/admin/images/delete.gif" title="删除" border="0"/></a></td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delNewsInfo()" value="删除" class="buttab"/>
 
				<input type="button" name="sortN" onclick="sortNews(this)" value="排序" class="buttab"/>
         <%
        if(!up_classId.equals("000000000000000")){        
        %>
		   
         <input type="button" name="ret" onclick="window.location.href='/program/admin/category/index.jsp?class_type=<%=class_type%>&up_classId=<%=break_cat_id%>'" value="返回" class="buttab"/>
		   
		   <%}%>

			</td>
			<td>
				总计:<%=counter %>条

			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td align="center"><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
 
	  <input type="hidden" name="sort" id="sort" value="" />
    <input type="hidden" name="class_type" value="<%=class_type%>" id="class_type" />	
    <input type="hidden" name="up_classId" value="<%=up_classId%>" id="up_classId" />  
	  <input type="hidden" name="bpm_id" id="bpm_id" value="3694" />
	  </form>
</body>

</html>
